﻿
@page
@model AdminUI.Pages.OrderManage.OrderModel
@{
    var F = Html.F();
}

@section body {
    <f:Panel ID="Panel1" BodyPadding="5" ShowBorder="false" Layout="VBox" ShowHeader="false" IsViewPort="true">
        <Items>
            <f:Grid ID="Grid1" BoxFlex="1" ShowBorder="true" ShowHeader="false" EnableTextSelection="true" EnableColumnLines="true" EnableCheckBoxSelect="false" EnableMultiSelect="false" AllowSorting="true" AllowPaging="true" IsDatabasePaging="true"
                DataIDField="OrderID" DataTextField="GoodsName" SortingCancel="true" SortingToolTip="true" PageSize="@ViewBag.PageSize" RecordCount="@ViewBag.Total" DataSource="@ViewBag.DataSource"
                OnSort="@Url.Handler("Grid_DoAction")" OnSortFields="Panel1" OnPageIndexChanged="@Url.Handler("Grid_DoAction")" OnPageIndexChangedFields="Panel1">
                <Toolbars>
                    <f:Toolbar ID="Toolbar1" ToolbarAlign="Right" ItemSpace="1">
                        <Items>
                            <f:Button ID="btnDetails" IconAlign="Left" EnableDefaultState="false" IconFont="_List" Text="详情" OnClientClick="onDetailsClick();"></f:Button>
                            <f:ToolbarSeparator></f:ToolbarSeparator>
                            <f:Button ID="btnRefresh" IconAlign="Left" EnableDefaultState="false" IconFont="_Refresh" Text="刷新" OnClientClick="onRefreshClick();"></f:Button>
                            <f:ToolbarFill ID="ToolbarFill1"></f:ToolbarFill>
                            <f:DropDownList ID="Status" Label="" SelectedValue="0" Width="150">
                                <f:ListItem Text="== 请选择订单状态 ==" Value="0" />
                                <f:ListItem Text="待支付" Value="10" />
                                @* <f:ListItem Text="已取消" Value="11" /> *@
                                <f:ListItem Text="待审核" Value="20" />
                                <f:ListItem Text="待发货" Value="30" />
                                <f:ListItem Text="已完成" Value="100" />
                            </f:DropDownList>
                            <f:DropDownList ID="Condition" SelectedValue="" Width="150">
                                <f:ListItem Text="== 请选择条件 ==" Value="" />
                                <f:ListItem Text="订单ID" Value="OrderID" />
                                <f:ListItem Text="会员ID" Value="UserID" />
                                <f:ListItem Text="姓名" Value="TrueName" />
                                <f:ListItem Text="手机号" Value="Mobile" />
                            </f:DropDownList>
                            <f:TriggerBox ID="Keyword" ShowLabel="false" EmptyText="请输入搜索关键字" TriggerIcon="Search" OnTriggerClick="@Url.Handler("Grid_DoAction")" OnTriggerClickFields="Panel1">
                            </f:TriggerBox>
                        </Items>
                    </f:Toolbar>
                </Toolbars>
                <Columns>
                    <f:RenderField HeaderText="订单ID" DataField="OrderID" FieldType="Int" QuickSortField="true" Width="150" TextAlign="Center" />
                    @* <f:RenderField HeaderText="租户" DataField="TID" FieldType="Int" Hidden="@Model.OnlineTID > 0" Width="60" TextAlign="Center" /> *@
                    <f:RenderField HeaderText="会员信息" DataField="UserID" FieldType="Int" Width="260" RendererFunction="renderMemberInfo" />
                    <f:RenderField HeaderText="用户类型" DataField="UserType" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="用户姓名" DataField="TrueName" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="手机号" DataField="Mobile" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="收货人电话" DataField="ReceiverPhone" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="收货人姓名" DataField="ReceiverName" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="收货地址" DataField="ReceivingAddress" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="收货区县ID" DataField="CountyID" FieldType="Int" Width="80" Hidden="true" />
                    <f:RenderField HeaderText="推荐人" DataField="RecoID" FieldType="Int" Width="150" RendererFunction="renderReco" />
                    <f:RenderField HeaderText="推荐人姓名" DataField="RecoName" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="推荐人ID2" DataField="RecoID2" FieldType="Int" Width="80" Hidden="true" />
                    <f:RenderField HeaderText="推荐人姓名2" DataField="RecoName2" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="代理ID" DataField="AgentID" FieldType="Int" Width="80" TextAlign="Right" Hidden="true" />
                    <f:RenderField HeaderText="代理" DataField="AgentName" Width="70" />

                    <f:RenderField HeaderText="数量" DataField="Total" FieldType="Int" Width="60" TextAlign="Right" />
                    <f:RenderField HeaderText="总金额" DataField="Amount" FieldType="Double" Width="80" TextAlign="Right" />
                    <f:RenderField HeaderText="抵扣" DataField="DeductionAmount" FieldType="Double" Width="70" TextAlign="Right" />
                    <f:RenderField HeaderText="成本" DataField="Cost" FieldType="Double" Width="70" TextAlign="Right" />
                    <f:RenderField HeaderText="业绩" DataField="Commission" FieldType="Double" Width="90" TextAlign="Right" />
                    <f:RenderField HeaderText="直推" DataField="L1Fee" FieldType="Double" Width="90" TextAlign="Right" />
                    <f:RenderField HeaderText="间推" DataField="L2Fee" FieldType="Double" Width="90" TextAlign="Right" />
        			
        			@* <f:RenderField HeaderText="物流公司" DataField="ExpressCompany" Width="100" />
        			<f:RenderField HeaderText="物流单号" DataField="ExpressNo" Width="100" /> *@
        			@* <f:RenderField HeaderText="转账日期" DataField="TransferDate" FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd" Width="100" TextAlign="Center" />
        			<f:RenderField HeaderText="转账备注" DataField="TransferMemo" Width="100" />
        			<f:RenderField HeaderText="交易流水号" DataField="TradeNo" Width="100" />
        			<f:RenderField HeaderText="收款账号" DataField="PayeeAccount" Width="100" /> *@
		@* 			<f:RenderField HeaderText="审核员ID" DataField="AuditorID" FieldType="Int" Width="80" TextAlign="Right" />
        			<f:RenderField HeaderText="审核员姓名" DataField="AuditorName" Width="100" />
        			<f:RenderField HeaderText="审核时间" DataField="AuditingTime" FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd" Width="100" TextAlign="Center" />
					<f:RenderField HeaderText="发货人ID" DataField="ShipperID" FieldType="Int" Width="80" TextAlign="Right" />
        			<f:RenderField HeaderText="发货人姓名" DataField="ShipperName" Width="100" />
        			<f:RenderField HeaderText="发货时间" DataField="DeliveryTime" FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd" Width="100" TextAlign="Center" /> *@
                    <f:RenderField HeaderText="状态" DataField="Status" RendererFunction="renderOrderStatus" FieldType="Int" Width="80" TextAlign="Center" />
                    <f:RenderField HeaderText="创建时间" DataField="CreateTime" FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd HH:mm" Width="140" TextAlign="Center" />
                </Columns>
                <PageItems>
                    <f:ToolbarSeparator></f:ToolbarSeparator>
                    <f:ToolbarText Text="每页记录数："></f:ToolbarText>
                    <f:DropDownList ID="ddlGridPageSize" Width="60" SelectedValue="@ViewBag.PageSize" OnSelectedIndexChanged="@Url.Handler("Grid_DoAction")" OnSelectedIndexChangedFields="Panel1">
                        <Items>
                            <f:ListItem Text="10" Value="10"></f:ListItem>
                            <f:ListItem Text="20" Value="20"></f:ListItem>
                            <f:ListItem Text="30" Value="30"></f:ListItem>
                            <f:ListItem Text="50" Value="50"></f:ListItem>
                            <f:ListItem Text="100" Value="100"></f:ListItem>
                            <f:ListItem Text="200" Value="200"></f:ListItem>
                        </Items>
                    </f:DropDownList>
                </PageItems>
            </f:Grid>
        </Items>
    </f:Panel>

    <f:Window ID="Window1" IsModal="true" Hidden="true" Target="Top" EnableResize="true" EnableMaximize="true" EnableIFrame="true" Width="960" Height="720">
        @*<Listeners>
                <f:Listener Event="close" Handler="onWindowClose('refresh');"></f:Listener>
            </Listeners>*@
    </f:Window>
}

@section script {
    <script src="~/res/js/grid.js"></script>
    <script>

        function onDetailsClick(event) {
            var grid1 = F.ui.Grid1;
            if (!grid1.hasSelection()) {
                showNotify('请选择要查看的记录！');
                return;
            }

            var selectedRow = grid1.getSelectedRow();
            var path = "/Mall/OrderDetails?id=" + selectedRow;
            F.ui.Window1.show(path, '查看订单详情', 1200, 800);
        }
        function onDeleteClick(event) {
            var grid1 = F.ui.Grid1;
            if (!grid1.hasSelection()) {
                showNotify('请选择要删除的记录！');
                return;
            }

            var selectedRows = grid1.getSelectedRows();
            F.confirm({
                message: '确定要删除所选记录吗？',
                target: '_top',
                ok: function () {
                    F.doPostBack('@Url.Handler("Grid_DoAction")', 'Panel1', {
                        actionType: 'delete',
                        selectedIDs: selectedRows
                    });
                }
            });
        }
        function onCancelClick(event) {
            var grid1 = F.ui.Grid1;
            if (!grid1.hasSelection()) {
                showNotify('请选择要取消的记录！');
                return;
            }

            var selectedRows = grid1.getSelectedRows();
            F.confirm({
                message: '确定要取消所选记录吗？',
                target: '_top',
                ok: function () {
                    F.doPostBack('@Url.Handler("Grid_DoAction")', 'Panel1', {
                        actionType: 'cancel',
                        selectedIDs: selectedRows
                    });
                }
            });
        }
        function onRefreshClick() {
            F.doPostBack('@Url.Handler("Grid_DoAction")', 'Panel1');
        }

        //会员信息
        function renderMemberInfo(value, params) {
            var member = value + "-" + params.rowData.values.UserType + "-" + params.rowData.values.TrueName + "-" + params.rowData.values.Mobile;
            var receiver = params.rowData.values.ReceiverName + "-" + params.rowData.values.ReceiverPhone + "-" + params.rowData.values.ReceivingAddress;

            // return F.formatString('<font size="2">{0},{1}</font>', member,receiver);
            return F.formatString('<font size="2">{0}</font>', member);
        }

        function renderReco(value, params) {
            var reco = "";
            if (value > 0) {
                // reco = params.rowData.values.RecoID + "-" + params.rowData.values.RecoName;
                reco = params.rowData.values.RecoName;

                var id2 = params.rowData.values.RecoID2;
                if (id2 > 0) {
                    // reco += "=>" + params.rowData.values.RecoID2 + "-" + params.rowData.values.RecoName2;
                    reco += "=>" + params.rowData.values.RecoName2;
                }
            }

            return reco;
        }

        //图片预览
        function renderImage(value, params) {
            return '<a href="javascript:;" class="imagePreview"><img style="width:58px;height:45px;margin:0,auto;" src="' + value + '"/></a>';//自定义图片按钮
        }

        F.ready(function () {
            var preview = new Preview({
                imgWrap: 'Grid1' // 指定该容器里的图片点击预览
            })
        });

    </script>
    <script src="~/res/third-party/jspciyl/preview.js"></script>
}

@section head {
    <link rel="stylesheet" type="text/css" href="~/res/third-party/jspciyl/preview.css" />

    <style>

        .f-grid-cell.f-grid-cell-RecoID .f-grid-cell-inner {
            white-space: normal;
            word-break: break-all;
        }
    </style>

}
